package com.neuedu.controller;

import com.neuedu.bean.Business;
import com.neuedu.common.R;
import com.neuedu.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/business")
@CrossOrigin
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    @GetMapping("/listBusinessByOrderTypeId/{orderTypeId}")
    public R listBusinessByOrderTypeId(@PathVariable("orderTypeId") String orderTypeId) {
        try {
            List<Business> businessList = businessService.listBusinessByOrderTypeId(orderTypeId);
            return R.ok().data(businessList);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @GetMapping("/getBusinessById/{businessId}")
    public R getBusinessById(@PathVariable("businessId") String businessId) {
        try {
            Business business = businessService.getBusinessById(businessId);
            return R.ok().data(business);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }



}
